﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admincp_namhoc : AdminPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void Page_PreRender(object sender, EventArgs e)
    {
        this.FillDataToListView();
    }

    private void FillDataToListView()
    {
        lvNamHoc.DataSource = db.NamHocs;
        lvNamHoc.DataBind();
    }

    protected void ThemMoiNamHoc(object sender, EventArgs e)
    {
        Response.Redirect("qlnamhoc.aspx?hanhdong=themmoi");
    }
    protected void lvNamHoc_ItemDeleting(object sender, ListViewDeleteEventArgs e)
    {

    }
    protected void lvNamHoc_ItemEditing(object sender, ListViewEditEventArgs e)
    {

    }
    protected void lvNamHoc_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        switch (e.CommandName)
        {
            case "EDIT":
                Response.Redirect("qlnamhoc.aspx?hanhdong=capnhat&manamhoc=" + e.CommandArgument.ToString());
                break;
            case "DELETE":
                NamHoc namhoc = db.NamHocs.Single(nh => nh.MaNamHoc == e.CommandArgument.ToString());
                db.NamHocs.DeleteOnSubmit(namhoc);
                db.SubmitChanges();
                this.FillDataToListView();
                break;
        }
    }
}